In article <clive-0407952145410001@ctwilson.demon.co.uk>,
clive@ctwilson.demon.co.uk (Clive Wilson) wrote:
> Is there any easy way of having a small number of preferences stored in
> the resource fork of an application?
>
> I'm using THINK Pascal and really don't want to have to have the hassle of
> hunting the Preferences folder for my prefs. In any case it's more robust
> having them located with their application.
>
> If there is a way of doing this, I would be really grateful if someone
> could suggest some means of doing it.
>
> Many thanks in anticipation,
Maybe I'm silly, but this is how I (and most everyone I work with) view
resources as preferences:
>From exprience, I do not trust the resource manager to write resources.
Anytime I have written a program that writes resources (for preferences or
whatever), The resource fork has eventually become corrupted. (Have you
ever had a tech support person tell you to "try trashing your prefs and
restart"?)
I view resources as READ ONLY. I would strongly recomend storing your
preferences in the data fork.
Bill Hubauer
MSA
+++++++++++++++++++++++++++
>From mouser@zercom.net (Martin-Gilles Lavoie)
Date: 7 Jul 1995 12:35:12 GMT
Organization: zercom technologies inc.
In article <clive-0407952145410001@ctwilson.demon.co.uk>,
clive@ctwilson.demon.co.uk (Clive Wilson) wrote:
> Is there any easy way of having a small number of preferences stored in
> the resource fork of an application?
>
> I'm using THINK Pascal and really don't want to have to have the hassle of
> hunting the Preferences folder for my prefs. In any case it's more robust
> having them located with their application.
>
> If there is a way of doing this, I would be really grateful if someone
> could suggest some means of doing it.
>
> Many thanks in anticipation,
>
> Clive Wilson
Storing prefs in your app would be unadvisable for many reasons. Those at the top of my head are that the user may be running the software off a locked volume, or a shared environement. Shall the user's machine freeze for some reason while your software is playing with itself may cause some irreparable dammages to the application (AND preferences data), forcing the user to re-install the app and reset the preferences (no matter how small prefs are, I've noted users hate having to set them again).
Here's code you can use to easilly locate a pref file in the preferences folder:
OSErr osErr = noErr;
FSSpec prefFileSpecs;
short foundVRefNum = 0;
long foundDirID = 0;
osErr = FindFolder( kOnSystemDisk,
kPreferencesFolderType,
kCreateFolder,
&foundVRefNum,
&foundDirID);
if (osErr == noErr) {
osErr = FSMakeFSSpec( foundVRefNum,
foundDirID,
(unsigned char*) "\My Pref File Name",
&prefFileSpecs);
}
At this point, all you have to do is open your pref file resource fork with
> > >From exprience, I do not trust the resource manager to write resources.
> > Anytime I have written a program that writes resources (for preferences or
> > whatever), The resource fork has eventually become corrupted. (Have you
> > ever had a tech support person tell you to "try trashing your prefs and
> > restart"?)
>
> Oh, c'mon; prefs files get trashed because some appls leave the prefs
> files open and in the event of a crash any open file has a good
> chance of being trashed. There's no law that says that you *must*
> leave the prefs file open - you can read in the prefs, close the
> file, and re-open it when the user changes something. The data fork
> can get trashed in just the same way...
>
Another possible reason for corrupting the resource fork is if you fail to
delete an existing resource before you write a new one with the same type
and ID. This will result in multiple resources of the same type and ID
(i.e., a corrupt resource map). Of course, if you always delete and
create a new prefs file from scratch, you're fine. Also, if you always do
a GetResource first and simply modify its contents, if it already exist,
you're also fine.
--
Scott Lindsey <wombat@claris.com>
The opinions expressed herein are those of the author and not necessarily those of Claris, Apple, Adobe, Novell, IBM, General Motors, or any other company, government, or organization.
---------------------------
>From ken@zn.ruhr-uni-bochum.de (Ken Flaton)
Subject: TextBox & Transfer Mode?!
Date: Mon, 17 Jul 1995 19:47:18 +0200
Organization: Zentrum fuer Neuroinformatik
Very briefly: is it possible to write text using TextBox() and get a srcOr
instead of what looks like a srcCopy for a transfer mode? This is driving
me nuts...
Less briefly: how??
TIA,
--ken
*************************************
* Dr. Ken Flaton *
* Zentrum fuer Neuroinformatik *
* Bochum, Germany *
* *
* email: ken@zn.ruhr-uni-bochum.de *
*************************************
+++++++++++++++++++++++++++
>From brians@pbcomputing.com (Brian Stern)
Date: 18 Jul 1995 04:13:40 GMT
Organization: The University of Texas at Austin, Austin, Texas
In article <ken-1707951947180001@fangorn.zn.ruhr-uni-bochum.de>,
ken@zn.ruhr-uni-bochum.de (Ken Flaton) wrote:
<Very briefly: is it possible to write text using TextBox() and get a srcOr
<instead of what looks like a srcCopy for a transfer mode? This is driving
<me nuts...
<
<Less briefly: how??
<
<TIA,
<
<--ken
<
<
<*************************************
<* Dr. Ken Flaton *
<* Zentrum fuer Neuroinformatik *
<* Bochum, Germany *
<* *
<* email: ken@zn.ruhr-uni-bochum.de *
<*************************************
TETextBox does an EraseRect() on the rect that you pass to it before it
draws the text. The result is that whatever you ask it to do appears as
if you've used srcCopy. DrawString will work for most uses of TETextBox.
TETexctBox does give you multiple lines if you need that. The
justification it gives you can easily be obtained with DrawString.